package com.jiuxian.scheduling.commons;

import java.io.Serializable;

/**
 * Created by wangjingqing on 2017/11/9.
 */
public class ResponseEntity<T>  implements Serializable{

    private String code;

    private T data;


    private ResponseEntity(String code,T data){
        this.code = code;
        this.data = data;
    }

    public static <T> ResponseEntity seccuess(T data){
        return new ResponseEntity("0",data);
    }

    public static <T> ResponseEntity error(String code,T data){
        return new ResponseEntity(code,data);
    }

    public static ResponseEntity error(ErrorType error){
        return new ResponseEntity(error.getCode(),error.getMsg());
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "ResponseEntity{" +
                "code='" + code + '\'' +
                ", data=" + data +
                '}';
    }
}
